package org.neuedu.his.service;

import org.neuedu.his.mapper.MenuMapper;
import org.neuedu.his.model.Menu;
import org.neuedu.his.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class MenuService {
    @Autowired
    MenuMapper menuMapper;

//    @Cacheable("cache1")
    public List<Menu> getMenus() {
        return menuMapper.getMenus();
    }

    public List<Menu> getMenusById() {
        User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return menuMapper.getMenusById(user.getId());

    }
}
